package com.midian.service.push.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.midian.common.dao.BaseDaoTemplet;
import com.midian.common.dao.OrderHelper;
import com.midian.common.dao.SearchHelper;
import com.midian.common.dao.SearchHelper.Type;
import com.midian.common.exception.BizException;
import com.midian.common.pager.Pager;
import com.midian.model.push.PushMsg;
import com.midian.service.common.BaseService;
import com.midian.service.push.IPushMsgService;

/**
 * 推送消息业务实现类
 * @author Mengfh
 *
 */
@Service("pushMsgService")
public class PushMsgServiceImpl extends BaseService implements IPushMsgService {
	/**推送消息DAO*/
	private BaseDaoTemplet<PushMsg> pushMsgDAO;
	
	@Resource(name = "pushMsgDAO")
	public void setPushMsgDAO(BaseDaoTemplet<PushMsg> pushMsgDAO) {
		this.pushMsgDAO = pushMsgDAO;
	}

	@Override
	public PushMsg add(PushMsg target) throws BizException {
		this.pushMsgDAO.add(target);
		return target;
	}

	@Override
	public void update(PushMsg target) throws BizException {
		this.pushMsgDAO.updateByConvertHql(target);
	}

	@Override
	public void delete(Serializable id) throws BizException {
		this.pushMsgDAO.delete(id);
	}

	@Override
	public void delete(Serializable[] ids) throws BizException {
		this.pushMsgDAO.delete(ids);
	}

	@Override
	public PushMsg get(Serializable id) throws BizException {
		return this.pushMsgDAO.get(id);
	}

	@Override
	public List<PushMsg> showList(PushMsg target, Pager pager, List<OrderHelper> helper) throws BizException {
		return this.pushMsgDAO.find(target, getSearchHelper(), helper, pager);
	}

	@Override
	public void opDelFlag(Serializable[] ids, Integer status) throws BizException {
		this.pushMsgDAO.opDelFlag(ids, status);
	}

	@Override
	protected List<SearchHelper> getSearchHelper() {
		String[] attrs = {"delFlag"};
		Type[] types = {Type.EQ};
		return SearchHelper.getSearchList(attrs, types);
	}
}
